package com.boot.application;

import com.boot.application.bean.Pet;
import com.boot.application.config.Myconfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @Date 2021/6/18 14:57
 * @Created by wangle
 * @Description 主程序类
 */
@Slf4j //日志组件
@SpringBootApplication //这是一个springboot应用
public class MainApplication {
    public static void main(String[] args) {

        //1.返回我们ioc容器
       ConfigurableApplicationContext run= SpringApplication.run(MainApplication.class,args);
       //2.查看容器里的组件
        String [] names=run.getBeanDefinitionNames();
//        for(String name:names){
//            System.out.println(name);
//
//        }
        //3.从容器中获取组件
        Pet tom1=run.getBean("tom",Pet.class);
        Pet tom2=run.getBean("tom",Pet.class);
//        System.out.println(tom2.equals(tom1));

        log.info("请求进来了");
        Myconfig myconfig=run.getBean(Myconfig.class);
        System.out.println(myconfig);



    }

}
